# list列表的常用操作
mylist = ["itcast","itheima","python"]
index = mylist.index("python")
print(f"python在列表下的索引为{index}")

# 如果列表中被查找的元素不存在，会报错
# index = mylist.index("hello")
# print(f"python在列表下的索引为{index}")

# 修改list中特定下标索引的值
mylist[0]="hello"
print(mylist)
# 指定位置插入insert
mylist.insert(1,"best")
print(mylist)
# 追加到尾部append
mylist.append("left")
print(mylist)
# 追加列表
mylist2=[1,2,3,4,5]
mylist.extend(mylist2)
print(mylist)
# 删除元素1
mylist = ["itcast","itheima","python"]
del mylist[2]
print(mylist)
# 删除元素2
mylist =["itcast","itheima","python"]
element=mylist.pop(2)
print(mylist)
# 删除某元素在列表中的第一个匹配项
mylist = ["itcast","itheima","itcast","itheima","python"]
mylist.remove("itheima")
print(mylist)
# 清空列表
mylist.clear()
print(mylist)
# 统计单个
mylist = ["itcast","itheima","itcast","itheima","python"]
count=mylist.count("itheima")
print(count)
# 统计所有
mylist = ["itcast","itheima","itcast","itheima","python"]
count2=len(mylist)
print(count2)